/*
 * Expander.h
 *
 *  Created on: Jul 6, 2009
 *      Author: mlrus
 *      The "Expander" class provides a wrapper for an instance of the expansion operator (i.e. horizontal or vertical).
 *      This is a convenience class to keep the bindings "straight" as non-combining operators are invoked in their own wrappers
 */

#ifndef EXPANDER_H_
#define EXPANDER_H_

#include <sstream>
#include <iostream>
#include <ostream>

#include "Common.h"
#include "Dictionary.h"
#include "Cell.h"
#include "ExpansionOP.h"

class Scrabble;

class Expander {
friend class Scrabble;
	Scrabble *scrabble;
	ExpansionOP *expansionOp;
	uint d;

	Expander(const Expander&);
	void operator=(const Expander&);

	inline Cell *expandEndpoints(Cell* from, Cell* to, Cell *&startWord, Cell *&endWord, int direction);
	public:
		 uint testBoard(Cell *startWord, Cell *endWord,  Cell *expandLoc, Axis::Axis axis);

		Expander(Scrabble* scrabble, ExpansionOP *expansionOp) :
					scrabble(scrabble),
					expansionOp(expansionOp), d(0) {
		}

		virtual ~Expander() {
		}

		string describe() {
			std::ostringstream str;
			str << expansionOp->describe();
			return str.str();
		}

		inline Axis::Axis getAxis() {
			return expansionOp->getAxis();
		}
		int applyOperatorSequences(const Cell *cell);
		int applyOperatorSequences(const int nextExpanderIndex, const Cell *cell, const char *rack);
};

#endif /* EXPANDER_H_ */
